<?php

/**
 * 菜单控制器
 * @author Administrator
 *
 */
class Menu extends MY_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('Identity_model', 'id');
        $this->id->is_auth();
        $this->load->model('system_menu_model');
    }

    public function index()
    {
        $this->display("views/manage/menu_settings.html");
    }
    /**
     * 查询全部菜单
     */
    public function get_menu()
    {
        $json_data = $this->system_menu_model->get_system_menu_all();
        echo json_encode($json_data);
    }
    /**
     * 添加方法
     */
    public function addedit_system_menu()
    {
        //得到处理
        $replace_data = $this->input->post();
        //调用数据库方法
        $json_data = $this->system_menu_model->replace_system_menu($replace_data);//调用model
        echo json_encode($json_data);
    }

    /**
     * post获取菜单类型和父类id
     */
    public function get_system_menu_type()
    {
        $type = $this->input->post('type');//post 获取
        $parent_id = $this->input->post('parent_id');//post 获取
        $res_data = $this->system_menu_model->get_system_menu_select($type, $parent_id);
        echo json_encode($res_data);
    }

    /**
     * 根据id查询数据
     */
    public function get_system_menu()
    {
        $id = $this->input->post('id');//post 获取id
        $res_data = $this->system_menu_model->get_system_menu_id($id);//调用 model
        echo json_encode($res_data);
    }
}